import request from '@/config/axios'

// 定位信息 VO
export interface LocationVO {
  id: number // 主键ID
  locationTime: Date // 定位时间
  personId: number // 所属重点人ID
  lng: number // 经度
  lat: number // 纬度
  address: string // 详细地址
  dataType: number // 数据类型:1-人脸抓拍位置;2-航班
  cameraNo: string // data_type=1时，相机编码
  faceUrl: string // 人脸图片路径
}

export interface FrequentLocation {
  address: string
  count: number
  firstTime: string
  lastTime: string
  lng?: number
  lat?: number
}

// 定位信息 API
export const LocationApi = {
  // 查询定位信息分页
  getLocationPage: async (params: any) => {
    return await request.get({url: `/member/location/page`, params})
  },

  // 常去地统计接口
  getFrequentLocations: async (personId: number) => {
    return await request.get({url: `/member/location/frequent/?personId=` + personId})
  },

  // 查询定位信息详情
  getLocation: async (id: number) => {
    return await request.get({ url: `/member/location/get?id=` + id })
  },

  // 新增定位信息
  createLocation: async (data: LocationVO) => {
    return await request.post({ url: `/member/location/create`, data })
  },

  // 修改定位信息
  updateLocation: async (data: LocationVO) => {
    return await request.put({ url: `/member/location/update`, data })
  },

  // 删除定位信息
  deleteLocation: async (id: number) => {
    return await request.delete({ url: `/member/location/delete?id=` + id })
  },

  // 导出定位信息 Excel
  exportLocation: async (params) => {
    return await request.download({ url: `/member/location/export-excel`, params })
  }
}
